package _92XiangYuan.factory;

import _92XiangYuan.Shape;
import _92XiangYuan.impl.Circle;

import java.util.HashMap;
import java.util.Map;

/**
 * @ShapeFactory: 图形工厂
 * @author: ZBoHang
 * @time: 2021/9/14 15:44
 */
public class ShapeFactory {
    private static final Map<String, Shape> circleMap = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle circle = ((Circle) circleMap.get(color));
        if (circle == null) {
            circle = new Circle(color);
            circleMap.put(color, circle);
            System.out.println("通过工厂创建了个圆");
        }
        return circle;
    }
}
